<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>后台管理系统</title>
        <meta name="author" content="BaiYY"/>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <meta name="renderer" content="webkit">
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/bootstrap.min.css"/>
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/bootstrap-datetimepicker.min.css"/>
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/Font/css/font-awesome.min.css"/>
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/index.css"/>
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/pages.css"/>
        <script type="text/javascript" src="__PUBLIC__/admin/js/jquery.js"></script>
        <script type="text/javascript" src="__PUBLIC__/admin/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="__PUBLIC__/admin/js/index.js"></script>
        <script type="text/javascript" src="__PUBLIC__/admin/js/time.js"></script>
        <script type="text/javascript" src="__PUBLIC__/admin/js/pages.js"></script>
        <script type="text/javascript" src="__PUBLIC__/admin/js/bootstrap-datetimepicker.min.js"></script>
        <script type="text/javascript" src="__PUBLIC__/admin/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
    </head>
    <body>
    <div class="right-sidebar" style="max-width: 1200px;">
        <div>
            <p>说明：排行从上到下，默认时间是一周</p>
            <div class="form-group">
                <label for="start_time">开始时间</label>
                <input type="text" class="form-control" id="start_time" name="start_time" data-date-format="yyyy-mm-dd hh:ii:ss">
            </div>
            <div class="form-group">
                <label for="end_time">结束时间</label>
                <input type="text" class="form-control" id="end_time" name="end_time" data-date-format="yyyy-mm-dd hh:ii:ss">
            </div>
            <button type="submit" class="btn btn-primary" id="cbtn">查询</button>
        </div>
        <div class="table-responsive" style="margin-top: 15px;">
            <table class="table table-bordered">
                <thead>
                    <tr>
                        <th>排名</th>
                        <th>玩家ID</th>
                        <th>姓名</th>
                        <th>充值数量</th>
                    </tr>
                </thead>
                <tbody id="dataList"></tbody>
            </table>
        </div>
        <div style="width: 100%;">
            <ul class="page" id="page" style="width: 100%;overflow: hidden;"></ul>
        </div>
    </div>
    <script type="text/javascript">
        $(function () {
            $("#end_time").val(getLocalTime(new Date()/1000));
            $("#start_time").val(getLocalTime((new Date()/1000 - 604800)));
            $( "#start_time" ).datetimepicker({
                language: 'zh-CN',
                autoclose: 1,
                todayHighlight: 1,
                weekStart: 1,
                startDate: 0
            });
            $( "#end_time" ).datetimepicker({
                language: 'zh-CN',
                autoclose: 1,
                todayHighlight: 1,
                weekStart: 1,
                startDate: 0
            });
            $.ajax({
                type:"post",
                url:"{:U('Admin/Main/managePayBankData')}",
                success:function(datas) {
                    var num = 0;
                    for(var i=0;i<datas.length;i++) {
                        num++;
                        datas[i]['num_order'] = num;
                    }
                    if(datas == 'nodata') {
                        $("#dataList").html("暂时没有数据！");
                    }else{
                        options={
                            "id":"page",//显示页码的元素
                            "data":datas,//显示数据
                            "maxshowpageitem":2,//最多显示的页码个数
                            "pagelistcount":10,//每页显示数据个数
                            "callBack":function(data){
                                var str = "";
                                for(var i=0;i<data.length;i++) {
                                    str += "<tr><td>"+data[i].num_order+"</td><td>"+data[i].uid+"</td><td>"+data[i].uname+"</td><td>"+data[i].total_number+"</td></tr>";
                                }
                                $("#dataList").html(str);
                            }
                        }
                        page.init(datas.length,1,options);
                    }
                }
            })
        });

        $("#cbtn").on("click",function(){
            var start_time = new Date($("#start_time").val());
            start_time = Date.parse(start_time)/1000;
            var end_time = new Date($("#end_time").val());
            end_time = Date.parse(end_time)/1000;
            if($.trim($("#start_time").val()) == '' || $.trim($("#end_time").val()) == ''){
                alert("时间不能为空！");
                window.location.href="{:U('Admin/Main/managePayBank')}";
                return false;
            }
            if(start_time > end_time || start_time == end_time) {
                alert("请注意时间的先后顺序！");
                window.location.href="{:U('Admin/Main/managePayBank')}";
                return false;
            }

            $.ajax({
                type:"post",
                url:"{:U('Admin/Main/managePayBankSearch')}",
                dataType:"json",
                data:{'start_time':start_time,'end_time':end_time},
                success:function(datas) {
                    var num = 0;
                    for(var i=0;i<datas.length;++i) {
                        num ++;
                        datas[i]['num_order'] = num;
                    }
                    if(datas == 'nodata') {
                        $("#dataList").html("暂时没有数据！");
                    }else{
                        options={
                            "id":"page",//显示页码的元素
                            "data":datas,//显示数据
                            "maxshowpageitem":2,//最多显示的页码个数
                            "pagelistcount":10,//每页显示数据个数
                            "callBack":function(data){
                                var str = "";
                                for(var i=0;i<data.length;i++) {
                                    str += "<tr><td>"+data[i].num_order+"</td><td>"+data[i].uid+"</td><td>"+data[i].uname+"</td><td>"+data[i].total_number+"</td></tr>";
                                }
                                $("#dataList").html(str);
                            }
                        }
                        page.init(datas.length,1,options);
                    }
                }
            })
        })



        $(function () {
            $.ajax({
                type:"post",
                url:"{:U('Admin/Main/managePayBankData')}",
                success:function(datas) {
    //                console.log(datas);
                    var num = 0;
                    for(var i=0;i<datas.length;i++) {
                        num++;
                        datas[i]['num_order'] = num;
                    }
                    if(datas == 'nodata') {
                        $("#dataList").html("暂时没有数据！");
                    }else{
                        options={
                            "id":"page",//显示页码的元素
                            "data":datas,//显示数据
                            "maxshowpageitem":2,//最多显示的页码个数
                            "pagelistcount":10,//每页显示数据个数
                            "callBack":function(data){
                                var str = "";
                                for(var i=0;i<data.length;i++) {
                                    str += "<tr><td>"+data[i].num_order+"</td><td>"+data[i].uid+"</td><td>"+data[i].uname+"</td><td>"+data[i].total_number+"</td></tr>";
                                }
                                $("#dataList").html(str);
                            }
                        }
                        page.init(datas.length,1,options);
                    }
                }
            })
        })
    </script>
    </body>
</html>